<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"
%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"
%><%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"
%><%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"
%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
%>
<head>
    <title><fmt:message key="relationship" /></title>
</head>
<body>
    <h1><fmt:message key="relationship" /></h1>
    <c:url var="createUrl" value="/domain/relationship/create.action"/>
    <form:form action="${createUrl}" id="relationshipForm" modelAttribute="relationshipForm" >
        <form:errors cssClass="error"/>
        <table>
            <form:hidden path="relationship.inode"/>
            <tbody>
                <tr>
                    <th><fmt:message key="relationship_parentStructureInode" /></th>
                    <td>
                        <form:select path="relationship.parentStructureInode" items="${structures}" itemLabel="name" itemValue="inode" />
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "relationship.parentStructureInode",
                                widgetType : "dijit.form.FilteringSelect",
                                widgetAttrs : {
                                    required : true
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="relationship.parentStructureInode"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="relationship_parentRelationName" /></th>
                    <td>
                        <form:input path="relationship.parentRelationName"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "relationship.parentRelationName",
                                widgetType : "dijit.form.ValidationTextBox",
                                widgetAttrs : {
                                    required : true
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="relationship.parentRelationName"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="relationship_parentRequired" /></th>
                    <td>
                        <form:checkbox id="relationship.parentRequired" path="relationship.parentRequired"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "relationship.parentRequired",
                                widgetType : "dijit.form.CheckBox",
                                widgetAttrs : {
                                    checked: ${relationshipForm.relationship.parentRequired != null ? relationshipForm.relationship.parentRequired : false}
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="relationship.parentRequired"/>
                    </td>
                </tr>

                <tr>
                    <th><fmt:message key="relationship_childStructureInode" /></th>
                    <td>
                        <form:select path="relationship.childStructureInode" items="${structures}" itemLabel="name" itemValue="inode" />
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "relationship.childStructureInode",
                                widgetType : "dijit.form.FilteringSelect",
                                widgetAttrs : {
                                    required : true
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="relationship.childStructureInode"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="relationship_childRelationName" /></th>
                    <td>
                        <form:input path="relationship.childRelationName"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "relationship.childRelationName",
                                widgetType : "dijit.form.ValidationTextBox",
                                widgetAttrs : {
                                    required : true
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="relationship.childRelationName"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="relationship_childRequired" /></th>
                    <td>
                        <form:checkbox id="relationship.childRequired" path="relationship.childRequired"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "relationship.childRequired",
                                widgetType : "dijit.form.CheckBox",
                                widgetAttrs : {
                                    checked: ${relationshipForm.relationship.childRequired != null ? relationshipForm.relationship.childRequired : false}
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="relationship.childRequired"/>
                    </td>
                </tr>

                <tr>
                    <th><fmt:message key="relationship_cardinality" /></th>
                    <td>
                        <form:select path="relationship.cardinality" items="${cardinalities}" itemValue="value" itemLabel="displayName" />
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "relationship.cardinality",
                                widgetType : "dijit.form.FilteringSelect",
                                widgetAttrs : {
                                    required : true
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="relationship.cardinality"/>
                    </td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="2">
                        <div class="buttons">
                            <button id="saveButton" class="ok" type="submit"><fmt:message key="label.form.submit"/></button>
                            <script type="text/javascript">
                                Spring.addDecoration(new Spring.ValidateAllDecoration({
                                    elementId:'saveButton',
                                    event:'onclick'
                                }));
                            </script>
                        </div>
                    </td>
                </tr>
            </tfoot>
        </table>
    </form:form>
</body>
